Imports MIMS.WRS.Entities
Imports MIMS.WRS.Business

Public Class AQAddDialog
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub
    Protected WithEvents txtOrderNo As System.Web.UI.WebControls.TextBox
    Protected WithEvents ddlOffice As System.Web.UI.WebControls.DropDownList
    Protected WithEvents btnSearch As System.Web.UI.WebControls.Button
    Protected WithEvents rptResult As System.Web.UI.WebControls.Repeater

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Protected WithEvents calOrderDate As DateTimePicker

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Security.DenyIDSUser()

        If Not IsPostBack Then
            Me.ddlOffice.DataSource = OfficeService.GetOffices(OfficeColumns.OfficeName, MyFramework.OrderDirection.ASC)
            Me.ddlOffice.DataTextField = OfficeColumns.OfficeName.ToString()
            Me.ddlOffice.DataValueField = OfficeColumns.OfficeID.ToString()
            Me.ddlOffice.DataBind()

            ddlOffice.SelectedIndex = ddlOffice.Items.IndexOf(ddlOffice.Items.FindByValue(RequestContext.CurrentOffice.OfficeID.ToString()))
        End If
    End Sub

    Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        Dim supCode As Integer = -1
        Dim orderNo As Integer = -1
        Try
            supCode = Integer.Parse(RequestContext.SupplierCode)
        Catch ex As Exception
        End Try
        Try
            orderNo = Integer.Parse(txtOrderNo.Text)
        Catch ex As Exception

        End Try
        Dim orderDate As DateTime = New DateTime(1900, 1, 1)
        If (calOrderDate.SelectedValue <> Nulls.NullDate) Then orderDate = calOrderDate.SelectedValue
        Me.rptResult.DataSource = ShippingStatusReportService.GetShippingStatusReports(Integer.Parse(ddlOffice.SelectedItem.Value), _
            supCode, orderNo, orderDate, True)
        Me.rptResult.DataBind()


    End Sub
End Class
